import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import com.golden.gamedev.Game;
import com.golden.gamedev.GameLoader;
import com.golden.gamedev.object.Background;
import com.golden.gamedev.object.CollisionManager;
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.SpriteGroup;
import com.golden.gamedev.object.background.ColorBackground;


public class practiceGame2 extends Game {

	//{ distribute = true; } - allows a game to finish and no longer show rendering
    Background   background;
    SpriteGroup  PLAYER_GROUP, PLAYER_SHOT_GROUP,
                 ENEMY_GROUP;
    Sprite hero,villian;
    CollisionManager collision;


    public void initResources() {
    	hero = new Sprite(getImage("Bird.gif"), 0, 0);
        hero.setSpeed(.05, .1);
        
        villian = new Sprite(getImage("projectile.png"), 150, 200);
        villian.setSpeed(-.08, -.04);
    	
    	
    	
        background = new ColorBackground(Color.BLUE, 1024, 768);

        PLAYER_GROUP      = new SpriteGroup("Player Group");
        PLAYER_GROUP.add(new Sprite(getImage("Cat.gif"), 150, 200));

        PLAYER_SHOT_GROUP = new SpriteGroup("Player Shot Group");
        PLAYER_SHOT_GROUP.add(villian);

        ENEMY_GROUP = new SpriteGroup("Enemy Group");
        ENEMY_GROUP.add(hero);

        PLAYER_GROUP.setBackground(background);
        PLAYER_SHOT_GROUP.setBackground(background);
        ENEMY_GROUP.setBackground(background);
        
        collision = new PlayerShotToEnemyCollision();
        collision.setCollisionGroup(PLAYER_SHOT_GROUP, ENEMY_GROUP);
    }

    @Override
    public void update(long elapsedTime) {
        background.update(elapsedTime);

        PLAYER_GROUP.update(elapsedTime);
        PLAYER_SHOT_GROUP.update(elapsedTime);
        ENEMY_GROUP.update(elapsedTime);
        collision.checkCollision();
    }

    @Override
    public void render(Graphics2D g) {
        background.render(g);

        PLAYER_GROUP.render(g);
        PLAYER_SHOT_GROUP.render(g);
        ENEMY_GROUP.render(g);
    }


    public static void main(String[] args) {
        GameLoader game = new GameLoader();
        com.golden.gamedev.Game gamer = new practiceGame2();
        game.setup(gamer, new Dimension(640,480), false);
        game.start();
    }


}
